package com.menhai.personmanagement.controller;

import java.text.SimpleDateFormat;
import java.util.Date;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.menhai.personmanagement.entity.MbHealthSupervisionAssessment;
import com.menhai.personmanagement.entity.MbHealthSupervisionModel;
import com.menhai.personmanagement.services.MbHealthSupervisionService;

import lombok.extern.slf4j.Slf4j;
/**
 * <p>
 * 健康质量监督 前端控制器
 * </p>
 *
 * @author shikun
 * @since 2021-11-25
 */

@Slf4j
@RestController
@RequestMapping("/healthSupervision")
public class MbHealthSupervisionController {

     @Autowired
     private MbHealthSupervisionService mbHealthSupervisionService;
    
     
     /**
      * 健康监督显示患者
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/selectPatientList")
     public Object selectPatientList(HttpServletRequest request, HttpServletResponse response,MbHealthSupervisionModel mbHealthSupervisionModel){
    	String name = request.getParameter("name");
    	String hosnum = request.getParameter("hosnum");
		return mbHealthSupervisionService.getListByCondition(name,mbHealthSupervisionModel,hosnum);
     }
     
     
     /**
      * 新建健康质量监督模板
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/addMbHealthSupervisionModel")
     public Object addMbHealthAdviceModel(MbHealthSupervisionModel mbHealthSupervisionModel){
    	//新建时间
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		mbHealthSupervisionModel.setCreateTime(sdf.format(new Date()));
		return mbHealthSupervisionService.addMbHealthSupervisionModel(mbHealthSupervisionModel);
     }
     
     
     /**
      * 健康质量监督显示模板数据
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/getAdviceModelListByCondition")
     public Object getAdviceModelListByCondition(HttpServletRequest request, HttpServletResponse response){
    	String hosnum = request.getParameter("hosnum");   	 
		return mbHealthSupervisionService.getAdviceModelListByCondition(hosnum);
     }
     
     /**
      * 删除评估模板
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/deleteAdviceModel")
     public Object deleteAdviceModel(HttpServletRequest request, HttpServletResponse response){
    	String modelId = request.getParameter("modelId");   	 
		return mbHealthSupervisionService.deleteAdviceModel(modelId);
     }
     
     
     /**
      * 新建健康监督评估
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/addMbHealthAdvice")
     public Object addMbHealthAdvice(MbHealthSupervisionAssessment mbHealthSupervisionAssessment){
    	//新建时间
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		mbHealthSupervisionAssessment.setAddTime(sdf.format(new Date()));
		return mbHealthSupervisionService.addMbHealthAdvice(mbHealthSupervisionAssessment);
     }
     
     /**
      * 查看健康监督评估
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/getAdviceListByCondition")
     public Object getAdviceListByCondition(HttpServletRequest request, HttpServletResponse response){
    	String hosnum = request.getParameter("hosnum");
    	String bkbh = request.getParameter("bkbh");
    	String assessmentType = request.getParameter("assessmentType");
		return mbHealthSupervisionService.getAdviceListByCondition(hosnum,bkbh,assessmentType);
     }
     
     
     /**
      * 修改健康质量监督模板
      * @param request
      * @param response
      * @return
      */
     @RequestMapping("/updateMbHealthSupervisionModel")
     public Object updateMbHealthSupervisionModel(MbHealthSupervisionModel mbHealthSupervisionModel){
    	//新建时间
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		mbHealthSupervisionModel.setCreateTime(sdf.format(new Date()));
		return mbHealthSupervisionService.updateMbHealthSupervisionModel(mbHealthSupervisionModel);
     }
 	
}
